package com.org.service.impl.opera;

import com.github.pagehelper.Page;
import com.org.core.mybatis.PageUtil;
import com.org.dao.opera.DatabaseMapper;
import com.org.entity.base.PageRequest;
import com.org.entity.base.PageResult;
import com.org.entity.opera.Database;
import com.org.service.opera.DatabaseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class DatabaseServiceImpl implements DatabaseService {

    @Autowired
    private DatabaseMapper databaseMapper;

    /**
     * 获取数据库列表
     *
     * @return
     */
    @Override
    public List<Database> getDatabaseList() {
        return databaseMapper.getDatabaseList();
    }

    /**
     * 获取数据库分页列表
     *
     * @return
     */
    @Override
    public PageResult<Database> getDatabasePageList(PageRequest pageRequest) {
        Page<?> page = PageUtil.startPageAllowNull(pageRequest.getPageNum(), pageRequest.getPageSize());
        return new PageResult<>(getDatabaseList(), page.getTotal());
    }
}
